package com.neelsys.visualisation.repository.majorComb;

import java.util.List;

import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.CypherDslRepository;
import org.springframework.data.neo4j.repository.GraphRepository;
import org.springframework.data.neo4j.repository.NamedIndexRepository;
import org.springframework.data.neo4j.repository.RelationshipOperationsRepository;

import com.neelsys.visualisation.domain.CourseDesignator;
import com.neelsys.visualisation.domain.MajorCombination;

/**
 * 
 * 
 */
public interface MajorCombinationRepository extends
		GraphRepository<MajorCombination>,
		RelationshipOperationsRepository<MajorCombination>,
		NamedIndexRepository<MajorCombination>,
		CypherDslRepository<MajorCombination>, MajorCombinationExtensionRepo {
	MajorCombination findById(String id);

	MajorCombination findByCourseIdentifier(String courseIdentifier);

	MajorCombination findByCourseIdentifierAndMajorIdentifier(
			String courseIdentifier, String majorIdentifier);

	MajorCombination findByMajorIdentifierAndCourseDesignator(
			String majorIdentifier, CourseDesignator courseDesigntator);

	List<MajorCombination> findByCourseDesignator(
			CourseDesignator courseDesigntator);
	
	@Query("START majorCombination=node:MajorCombination(courseIdentifier={0}) MATCH (majorCombination)<-[:PRE_REQ_FOR|ELIGIBLE_FOR*]-(majorCombinationt) WHERE has(majorCombinationt.courseIdentifier) RETURN DISTINCT collect(majorCombinationt)")
	List<MajorCombination> findMajorCombinations(String courseIdentifier);	

}
